package com.itheima.controller;

import com.itheima.pojo.PageInfo;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin("*")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 获取总条数
     */
    @GetMapping("/count")
    public Integer selectCountUser() {
        return userService.selectCountUser();
    }

    /**
     * 分页查询
     *
     * @param current 当前页码
     * @param size    每页条数
     * @return
     */
    @GetMapping("/selectLimit/{current}/{size}")
    public PageInfo selectLimit(@PathVariable("current") Integer current,@PathVariable("size") Integer size) {
        PageInfo pageInfo = userService.selectLimit(current,size);
        return pageInfo;
    }

}
